/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('paiautoml', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AutofeExperimentConfiguration {
  odpsConfig?: {
    odpsAccessId?: string(name='odps_access_id'),
    odpsAccessKey?: string(name='odps_access_key'),
    odpsEndpoint?: string(name='odps_endpoint', description='This parameter is required.', example='http://service.cn-beijing.maxcompute.aliyun.com/api'),
    odpsProjectName?: string(name='odps_project_name', description='This parameter is required.'),
    odpsRegionId?: string(name='odps_region_id', description='This parameter is required.', example='cn-beijing'),
    odpsRoleArn?: string(name='odps_role_arn'),
  }(name='odps_config', description='This parameter is required.'),
  ossConfig?: {
    ossAccessId?: string(name='oss_access_id'),
    ossAccessKey?: string(name='oss_access_key'),
    ossBucket?: string(name='oss_bucket', description='This parameter is required.', example='autofe-service'),
    ossEndpoint?: string(name='oss_endpoint', description='This parameter is required.', example='oss-cn-beijing.aliyuncs.com'),
    ossRoleArn?: string(name='oss_role_arn'),
  }(name='oss_config', description='This parameter is required.'),
  ymlConfig?: {
    action?: string(name='action', example='train'),
    aggregateOnly?: string(name='aggregate_only', example='true'),
    analyzeExpId?: string(name='analyze_exp_id'),
    cpu?: string(name='cpu', example='2'),
    dataPartition?: string(name='data_partition'),
    dataSource?: string(name='data_source', description='This parameter is required.', example='odps_table_name'),
    dataType?: string(name='data_type', example='odps'),
    debugMode?: string(name='debug_mode', example='false'),
    excludeColumns?: string(name='exclude_columns'),
    featureSelection?: string(name='feature_selection'),
    filterThresh?: string(name='filter_thresh', example='10'),
    ivThresh?: string(name='iv_thresh', example='0.02'),
    label?: string(name='label', description='This parameter is required.', example='label'),
    memory?: string(name='memory', example='4000'),
    outputConfigOssDir?: string(name='output_config_oss_dir', description='This parameter is required.', example='oss://bucket_name/'),
    pipelineExpId?: string(name='pipeline_exp_id'),
    reuseResults?: string(name='reuse_results', example='false'),
    sampleRatio?: string(name='sample_ratio', example='0'),
    sampleSize?: string(name='sample_size', example='5000000'),
    selectionExpId?: string(name='selection_exp_id'),
    skipSelect?: string(name='skip_select', example='true'),
    workers?: string(name='workers', example='10'),
    workspaceName?: string(name='workspace_name', description='This parameter is required.'),
  }(name='yml_config', description='This parameter is required.'),
}

model HpoExperimentConfig {
  dlcConfig?: {
    accessId?: string(name='access_id'),
    accessKey?: string(name='access_key'),
    endpoint?: string(name='endpoint'),
    protocol?: string(name='protocol'),
    region?: string(name='region'),
  }(name='dlc_config'),
  k8sConfig?: {
    nniContainerCpuLimit?: string(name='nni_container_cpu_limit'),
    nniContainerMemoryLimit?: string(name='nni_container_memory_limit'),
    nniContainerRequestedCpu?: string(name='nni_container_requested_cpu'),
    nniContainerRequestedMemory?: string(name='nni_container_requested_memory'),
  }(name='k8s_config'),
  metricConfig?: {
    finalMode?: string(name='final_mode', description='This parameter is required.'),
    metricDict?: map[string]any(name='metric_dict', description='This parameter is required.'),
    metricSource?: [ string ](name='metric_source', description='This parameter is required.'),
    metricType?: string(name='metric_type', description='This parameter is required.'),
    sourceListFinalMode?: string(name='source_list_final_mode'),
  }(name='metric_config', description='This parameter is required.'),
  monitorConfig?: {
    atMobiles?: string(name='at_mobiles'),
    atUserIds?: string(name='at_user_ids'),
    isAtAll?: string(name='is_at_all'),
    keyword?: string(name='keyword'),
    url?: string(name='url'),
  }(name='monitor_config'),
  odpsConfig?: {
    accessId?: string(name='access_id'),
    accessKey?: string(name='access_key'),
    endPoint?: string(name='end_point'),
    logViewHost?: string(name='log_view_host'),
    projectName?: string(name='project_name'),
    region?: string(name='region'),
    roleArn?: string(name='role_arn'),
  }(name='odps_config'),
  ossConfig?: {
    accessKeyID?: string(name='accessKeyID'),
    accessKeySecret?: string(name='accessKeySecret'),
    endpoint?: string(name='endpoint'),
    roleArn?: string(name='role_arn'),
  }(name='oss_config'),
  outputConfig?: {
    modelPath?: string(name='model_path'),
    summaryPath?: string(name='summary_path'),
  }(name='output_config'),
  paiflowConfig?: {
    accessKeyId?: string(name='access_key_id'),
    accessKeySecret?: string(name='access_key_secret'),
    regionId?: string(name='region_id'),
    workspaceId?: string(name='workspace_id'),
  }(name='paiflow_config'),
  paramsConfig?: {
    paramsSrcDstFilepath?: [ string ](name='params_src_dst_filepath', example='src_path,dst_file_path'),
  }(name='params_config'),
  platformConfig?: {
    cmd?: [ string ](name='cmd', description='This parameter is required.'),
    name?: string(name='name', description='This parameter is required.', example='DLC, MC,paiflow, etc'),
    resume?: string(name='resume'),
  }(name='platform_config', description='This parameter is required.'),
  scheduleConfig?: {
    day?: string(name='day'),
    endTime?: string(name='end_time'),
    startTime?: string(name='start_time'),
  }(name='schedule_config'),
  searchSpace?: map[string]any(name='search_space'),
  tsConfig?: {
    accessKeyId?: string(name='access_key_id'),
    accessKeySecret?: string(name='access_key_secret'),
    endpoint?: string(name='endpoint'),
    regionId?: string(name='region_id'),
  }(name='ts_config'),
  ymlConfig?: {
    assessor?: {
      classArgs?: {
        earlystop?: boolean(name='earlystop'),
        movingAvg?: string(name='moving_avg'),
        optimizeMode?: string(name='optimize_mode'),
        proportion?: float(name='proportion'),
        startStep?: int32(name='start_step'),
      }(name='class_args'),
      name?: string(name='name'),
    }(name='assessor'),
    debug?: boolean(name='debug'),
    experimentName?: string(name='experiment_name'),
    logLevel?: string(name='log_level'),
    maxTrialNumber?: int32(name='max_trial_number'),
    trialConcurrency?: int32(name='trial_concurrency'),
    tuner?: {
      classArgs?: map[string]any(name='class_args'),
      name?: string(name='name'),
    }(name='tuner'),
  }(name='yml_config'),
}

model CreateAutofeExperimentRequest {
  accessibility?: string(name='Accessibility', example='PUBLIC'),
  autofeExperimentConfiguration?: AutofeExperimentConfiguration(name='AutofeExperimentConfiguration'),
  description?: string(name='Description', example='This is an AutoFE experiment.'),
  name?: string(name='Name', description='This parameter is required.', example='my experiment x'),
  workspaceId?: string(name='WorkspaceId', example='283301'),
}

model CreateAutofeExperimentResponseBody = {
  code?: string(name='Code', example='INVALID_INPUT_PARAMS'),
  detail?: map[string]any(name='Detail', example='{}'),
  experimentId?: string(name='ExperimentId', example='t8cNdMO'),
  message?: string(name='Message', example='Missing \\\\"user_id\\\\" in request.'),
  requestId?: string(name='RequestId', example='22A1EC4E-15A2-51FF-BFA3-10D6735BAA69'),
}

model CreateAutofeExperimentResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateAutofeExperimentResponseBody(name='body'),
}

/**
 * @summary CreateAutofeExperiment
 *
 * @param request CreateAutofeExperimentRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateAutofeExperimentResponse
 */
async function createAutofeExperimentWithOptions(request: CreateAutofeExperimentRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateAutofeExperimentResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.accessibility)) {
    body['Accessibility'] = request.accessibility;
  }
  if (!Util.isUnset(request.autofeExperimentConfiguration)) {
    body['AutofeExperimentConfiguration'] = request.autofeExperimentConfiguration;
  }
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.name)) {
    body['Name'] = request.name;
  }
  if (!Util.isUnset(request.workspaceId)) {
    body['WorkspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateAutofeExperiment',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/autofe/experiment`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary CreateAutofeExperiment
 *
 * @param request CreateAutofeExperimentRequest
 * @return CreateAutofeExperimentResponse
 */
async function createAutofeExperiment(request: CreateAutofeExperimentRequest): CreateAutofeExperimentResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createAutofeExperimentWithOptions(request, headers, runtime);
}

model CreateHpoExperimentRequest {
  accessibility?: string(name='Accessibility', description='Experiment accesibility, public or private.', example='PRIVATE'),
  description?: string(name='Description', description='Experiment description.', example='This is an AutoML HPO experiment.'),
  hpoExperimentConfiguration?: HpoExperimentConfig(name='HpoExperimentConfiguration', description='The config object of the expriment.'),
  name?: string(name='Name', description='Experiment Name', example='my experiment x'),
  workspaceId?: string(name='WorkspaceId', description='AI Workspace ID', example='default'),
}

model CreateHpoExperimentResponseBody = {
  code?: string(name='Code', description='The HTTP status code. The status code 200 indicates that the request was successful.', example='INVALID_INPUT_PARAMS'),
  detail?: map[string]string(name='Detail', description='Detailed information of the failure.'),
  experimentId?: string(name='ExperimentId', description='Id of the request', example='sORVEck'),
  message?: string(name='Message', description='The error message returned.', example='Missing \\\\"user_id\\\\" in request.'),
  requestId?: string(name='RequestId', description='The request ID.', example='3F190916-B3E5-5D1E-AD0C-35C0DF105F51'),
}

model CreateHpoExperimentResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateHpoExperimentResponseBody(name='body'),
}

/**
 * @summary Create an HyperParameter Optimization experiment.
 *
 * @param request CreateHpoExperimentRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateHpoExperimentResponse
 */
async function createHpoExperimentWithOptions(request: CreateHpoExperimentRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateHpoExperimentResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.accessibility)) {
    body['Accessibility'] = request.accessibility;
  }
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.hpoExperimentConfiguration)) {
    body['HpoExperimentConfiguration'] = request.hpoExperimentConfiguration;
  }
  if (!Util.isUnset(request.name)) {
    body['Name'] = request.name;
  }
  if (!Util.isUnset(request.workspaceId)) {
    body['WorkspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateHpoExperiment',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Create an HyperParameter Optimization experiment.
 *
 * @param request CreateHpoExperimentRequest
 * @return CreateHpoExperimentResponse
 */
async function createHpoExperiment(request: CreateHpoExperimentRequest): CreateHpoExperimentResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createHpoExperimentWithOptions(request, headers, runtime);
}

model CreateServiceIdentityRoleResponseBody = {
  code?: string(name='Code', example='ExecutionFailure'),
  message?: string(name='Message', example='Execution failure, please try again.'),
  requestId?: string(name='RequestId', description='Id of the request', example='3F190916-B3E5-5D1E-AD0C-35C0DF105F51'),
  roleName?: string(name='RoleName', example='AliyunServiceRoleForPaiAutoml'),
}

model CreateServiceIdentityRoleResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateServiceIdentityRoleResponseBody(name='body'),
}

/**
 * @summary CreateServiceIdentityRole
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateServiceIdentityRoleResponse
 */
async function createServiceIdentityRoleWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): CreateServiceIdentityRoleResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'CreateServiceIdentityRole',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/serviceidentityrole`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary CreateServiceIdentityRole
 *
 * @return CreateServiceIdentityRoleResponse
 */
async function createServiceIdentityRole(): CreateServiceIdentityRoleResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createServiceIdentityRoleWithOptions(headers, runtime);
}

model DeleteHpoExperimentResponseBody = {
  code?: string(name='Code', description='The error code when the API call is not successful.', example='INVALID_USER_OR_EXP'),
  detail?: map[string]any(name='Detail', description='Extra info on the execution failure.', example='{}'),
  message?: string(name='Message', description='The error message returned.', example='Missing \\\\"user_id\\\\" in request.'),
  requestId?: string(name='RequestId', description='The request ID.', example='3F190916-B3E5-5D1E-AD0C-35C0DF105F51'),
}

model DeleteHpoExperimentResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteHpoExperimentResponseBody(name='body'),
}

/**
 * @summary Delete an HPO experiment
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteHpoExperimentResponse
 */
async function deleteHpoExperimentWithOptions(ExperimentId: string, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteHpoExperimentResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DeleteHpoExperiment',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}/delete`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Delete an HPO experiment
 *
 * @return DeleteHpoExperimentResponse
 */
async function deleteHpoExperiment(ExperimentId: string): DeleteHpoExperimentResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteHpoExperimentWithOptions(ExperimentId, headers, runtime);
}

model GetAutofeExperimentResponseBody = {
  code?: string(name='Code', example='INVALID_USER_OR_EXP'),
  creator?: string(name='Creator', example='266977839132045194'),
  detail?: map[string]any(name='Detail'),
  experimentId?: string(name='ExperimentId', example='tfKs0Ds'),
  gmtCreateTime?: string(name='GmtCreateTime', example='2023-08-18T09:41:01Z'),
  gmtModifiedTime?: string(name='GmtModifiedTime', example='2023-11-30T02:05:34.000Z'),
  jobMeta?: string(name='JobMeta', example='{"action": "fs_train", "request_id": "6B6D4FB6-87AA-5C0E-94AB-E0F830955D1E", "job_num": 7, "job_runs": [{"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-fqlk86bvk68", "duration": 181, "finish_at": 1719158854000, "create_time": "2024-06-23T16:04:31.000Z", "status": "Succeeded"}, {"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-q18k5jo66h3k", "duration": 233, "finish_at": 1719159106000, "create_time": "2024-06-23T16:07:51.000Z", "status": "Succeeded"}, {"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-g7b38dmqes0nm4le", "duration": 173, "finish_at": 1719159306000, "create_time": "2024-06-23T16:12:12.000Z", "status": "Succeeded"}, {"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-524dab97aazs3jmc", "duration": 199, "finish_at": 1719159527000, "create_time": "2024-06-23T16:15:28.000Z", "status": "Succeeded"}, {"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-a8z56wy2ppwmxx04", "duration": 197, "finish_at": 1719159747000, "create_time": "2024-06-23T16:19:08.000Z", "status": "Succeeded"}, {"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-2cgsbxzzzma1j", "duration": 210, "finish_at": 1719159982000, "create_time": "2024-06-23T16:22:51.000Z", "status": "Succeeded"}, {"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-3cgsvf3ien1cw7", "duration": 184, "finish_at": 1719160188000, "create_time": "2024-06-23T16:26:43.000Z", "status": "Succeeded"}], "workspace_id": "86006"}{"action": "fs_train", "request_id": "6B6D4FB6-87AA-5C0E-94AB-E0F830955D1E", "job_num": 7, "job_runs": [{"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-fqlk86betchc69vk68", "duration": 181, "finish_at": 1719158854000, "create_time": "2024-06-23T16:04:31.000Z", "status": "Succeeded"}, {"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-q18ijqak558jo66h3k", "duration": 233, "finish_at": 1719159106000, "create_time": "2024-06-23T16:07:51.000Z", "status": "Succeeded"}, {"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-g7b38df7mqes0nm4le", "duration": 173, "finish_at": 1719159306000, "create_time": "2024-06-23T16:12:12.000Z", "status": "Succeeded"}, {"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-524zedab97aazs3jmc", "duration": 199, "finish_at": 1719159527000, "create_time": "2024-06-23T16:15:28.000Z", "status": "Succeeded"}, {"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-a8z56wy2ppm6wmxx04", "duration": 197, "finish_at": 1719159747000, "create_time": "2024-06-23T16:19:08.000Z", "status": "Succeeded"}, {"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-2cgsbxzx9i35zzma1j", "duration": 210, "finish_at": 1719159982000, "create_time": "2024-06-23T16:22:51.000Z", "status": "Succeeded"}, {"job_url": "https://pai.console.aliyun.com/?projectId=&regionId=cn-beijing#/studio/task/detail/flow-3cgsvf3bprlien1cw7", "duration": 184, "finish_at": 1719160188000, "create_time": "2024-06-23T16:26:43.000Z", "status": "Succeeded"}], "workspace_id": "86006"}'),
  message?: string(name='Message', example='Missing \\\\"user_id\\\\" in request.'),
  name?: string(name='Name'),
  requestId?: string(name='RequestId', example='071A904D-5A49-597F-9F69-81C7701D04AC'),
  selectedFeatures?: string(name='SelectedFeatures', example='age,sex,education'),
  status?: string(name='Status', example='FINISHED, FAILED, USER_CANCELED'),
}

model GetAutofeExperimentResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetAutofeExperimentResponseBody(name='body'),
}

/**
 * @summary Get AutoFE Experiment。
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetAutofeExperimentResponse
 */
async function getAutofeExperimentWithOptions(ExperimentId: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetAutofeExperimentResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetAutofeExperiment',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/autofe/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Get AutoFE Experiment。
 *
 * @return GetAutofeExperimentResponse
 */
async function getAutofeExperiment(ExperimentId: string): GetAutofeExperimentResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getAutofeExperimentWithOptions(ExperimentId, headers, runtime);
}

model GetHpoExperimentResponseBody = {
  accessibility?: string(name='Accessibility', description='Accessibility of expriment, public or private.', example='PRIVATE'),
  code?: string(name='Code', description='Error when the API call is not success.', example='INVALID_INPUT_PARAMS'),
  configIni?: string(name='ConfigIni', description='Experiment run environment configurations.', example='[odps_config]
access_id=foo
access_key=bar
end_point=http://service.odps.aliyun.com/api
log_view_host=http://logview.odps.aliyun.com
project_name=my_project'),
  configYml?: string(name='ConfigYml', description='HPO search config yaml.', example='assessor:
  classArgs:
    optimize_mode: maximize
    start_step: 1
  name: PAIAssessor
debug: true
experimentName: maxcompute_kmeans_monitor
experimentWorkingDirectory: ../expdir
logLevel: debug
maxTrialNumber: 10
searchSpaceFile: search_space.json
trainingService:
  platform: local
trialCommand: python3 -m hpo_tools.core.utils.run --config=./config.ini
trialConcurrency: 2
tuner:
  classArgs:
    optimize_mode: maximize
  name: TPE'),
  creator?: string(name='Creator', description='The one who created the experiment.', example='123456789'),
  deleted?: boolean(name='Deleted', description='If the Experiment if deleted.', example='0'),
  description?: string(name='Description', description='Description of the experiment.', example='This is experiment is for tune the LR of model.'),
  detail?: map[string]any(name='Detail', description='Extra error message info.', example='TBD'),
  experimentId?: string(name='ExperimentId', description='Experiment ID.', example='sX5O9Q8'),
  gmtCreateTime?: string(name='GmtCreateTime', description='Experiment create time.', example='2024-01-01 08:30:11'),
  gmtModifiedTime?: string(name='GmtModifiedTime', description='Experiment last update time.', example='2024-01-01 08:30:11'),
  hpoExperimentConfiguration?: map[string]any(name='HpoExperimentConfiguration', description='Experiment configuration in json format.', example='{
    "output_config": {
        "model_path": "bi_ps_${exp_id}_${trial_id}"
    },
    "platform_config": {
        "cmd": [
            "PAI -name ps_smart\\\\n    -project foo",
            "PAI -name prediction\\\\n    -project foo",
            "PAI -name evaluate -project foo",
            "INSERT OVERWRITE TABLE my_table;"
        ],
        "name": "MaxCompute"
    },
    "metric_config": {
        "metric_dict": {
            "recall": 0.5,
            "auc": 0.25,
            "precision": 0.25
        },
        "metric_source": [
            "select * from my_metrics where pt=\\\\"${exp_id}_${trial_id}\\\\";"
        ],
        "metric_type": "table",
        "final_mode": "best"
    },
    "odps_config": {
        "project_name": "my_project",
        "role_arn": "acs:ram::123456789:role/aliyunserviceroleforfoo",
        "region": "cn-shanghai",
        "end_point": "http://service.cn.maxcompute.aliyun-inc.com/api",
        "log_view_host": "http://logview.odps.aliyun.com"
    },
    "yml_config": {
        "max_trial_number": 5,
        "assessor": {
            "name": "PAIAssessor",
            "class_args": {
                "earlystop": true,
                "start_step": 5,
                "optimize_mode": "maximize"
            }
        },
        "experiment_name": "my_exp",
        "tuner": {
            "name": "TPE",
            "class_args": {
                "optimize_mode": "maximize"
            }
        },
        "trial_concurrency": 2
    },
    "search_space": {
        "${max_depth}": {
            "_type": "choice",
            "_value": [
                1,
                3,
                5
            ]
        },
        "${tree_count}": {
            "_value": [
                50,
                100,
                150
            ],
            "_type": "choice"
        }
    }
}'),
  jobType?: string(name='JobType', description='Experiment  Job type.', example='1'),
  message?: string(name='Message', description='Error message.', example='Missing \\\\"user_id\\\\" in request.'),
  name?: string(name='Name', description='Experiment name.', example='my_hpo_exp_1'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='3F190916-B3E5-5D1E-AD0C-35C0DF105F51'),
  searchSpace?: string(name='SearchSpace', description='HPO hyperparameter search space.', example='{"${centerCount}":{"_type":"choice","_value":[2,3,4,5]},"${distanceType}":{"_type":"choice","_value":["euclidean","cosine","cityblock"]}}'),
  status?: string(name='Status', description='Experiment status.', example='INVALID_USER_OR_EXP, SUCCESS, or EXECUTION_FAILURE'),
  trialCount?: int32(name='TrialCount', description='Trials amount run till now.', example='3'),
  trialStatus?: map[string]string(name='TrialStatus', description='Status if a trial'),
  workspaceId?: string(name='WorkspaceId', description='AI Workspace ID.', example='12345'),
}

model GetHpoExperimentResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetHpoExperimentResponseBody(name='body'),
}

/**
 * @summary get hpo experiment by user id and exp id
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetHpoExperimentResponse
 */
async function getHpoExperimentWithOptions(ExperimentId: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetHpoExperimentResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetHpoExperiment',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary get hpo experiment by user id and exp id
 *
 * @return GetHpoExperimentResponse
 */
async function getHpoExperiment(ExperimentId: string): GetHpoExperimentResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getHpoExperimentWithOptions(ExperimentId, headers, runtime);
}

model GetHpoTrialResponseBody = {
  code?: string(name='Code', description='Error code.', example='INVALID_INPUT_PARAMS'),
  detail?: map[string]string(name='Detail', description='Extra error information.'),
  experimentId?: string(name='ExperimentId', description='Experiment ID.', example='abcde'),
  finalMetric?: string(name='FinalMetric', description='Final metric of the trial.', example='{"default":0.087745,"type":"FINAL","val_loss=([0-9\\\\\\\\\\\\\\\\.]+)":0.087745}'),
  gmtCreateTime?: string(name='GmtCreateTime', description='Trial create time.', example='2024-01-02 12:34:56'),
  gmtModifiedTime?: string(name='GmtModifiedTime', description='Trial last update time.', example='2024-01-02 21:32:56'),
  hyperparam?: string(name='Hyperparam', description='Hyperparameters used to run the trial.', example='{"${centerCount}": 5, "${distanceType}": "cosine"}'),
  jobMeta?: string(name='JobMeta', description='trial meta infomation.', example='{"nni_trial_id": "asdf", "nni_exp_id": "abcde", "nni_trial_sequence_id": 2}'),
  message?: string(name='Message', description='The error message.', example='Missing \\\\"user_id\\\\" in request.'),
  metric?: string(name='Metric', description='metric details uploaded during running.', example='[{"default":0.087745,"val_loss=([0-9\\\\\\\\\\\\\\\\.]+)":0.087745},
{"default":1.085841,"val_loss=([0-9\\\\\\\\\\\\\\\\.]+)":0.085841},
{"default":0.087745,"type":"FINAL","val_loss=([0-9\\\\\\\\\\\\\\\\.]+)":0.087745}]'),
  metricName?: string(name='MetricName', description='Name of the metric.', example='AUC or F1, Accuracy etc.'),
  model?: string(name='Model', description='Trial output model.', example='model_table_name_foo'),
  parameterId?: int32(name='ParameterId', description='Parameter id, start from 0.', example='0'),
  requestId?: string(name='RequestId', description='The request ID.', example='3F190916-B3E5-5D1E-AD0C-35C0DF105F51'),
  status?: string(name='Status', description='Trial status.', example='FINISHED, FAILED, USER_CANCELED'),
  trialId?: string(name='TrialId', description='Trail ID.', example='mf99W4'),
  userComment?: string(name='UserComment', description='User added comments.', example='best trial till now.'),
  userScore?: int32(name='UserScore', description='User updated score.', example='0'),
}

model GetHpoTrialResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetHpoTrialResponseBody(name='body'),
}

/**
 * @summary Get trial detail information
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetHpoTrialResponse
 */
async function getHpoTrialWithOptions(ExperimentId: string, TrialId: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetHpoTrialResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetHpoTrial',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}/trial/${OpenApiUtil.getEncodeParam(TrialId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Get trial detail information
 *
 * @return GetHpoTrialResponse
 */
async function getHpoTrial(ExperimentId: string, TrialId: string): GetHpoTrialResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getHpoTrialWithOptions(ExperimentId, TrialId, headers, runtime);
}

model GetServiceIdentityRoleResponseBody = {
  code?: string(name='Code', example='SUCCESS'),
  message?: string(name='Message', example='Execution failure, please try again.'),
  requestId?: string(name='RequestId', example='3F190916-B3E5-5D1E-AD0C-35C0DF105F51'),
  roleName?: string(name='RoleName', example='AliyunServiceRoleForPaiAutoml'),
}

model GetServiceIdentityRoleResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetServiceIdentityRoleResponseBody(name='body'),
}

/**
 * @summary GetServiceIdentityRole, return role name if SLR exists, empty otherwise
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetServiceIdentityRoleResponse
 */
async function getServiceIdentityRoleWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): GetServiceIdentityRoleResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetServiceIdentityRole',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/serviceidentityrole`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary GetServiceIdentityRole, return role name if SLR exists, empty otherwise
 *
 * @return GetServiceIdentityRoleResponse
 */
async function getServiceIdentityRole(): GetServiceIdentityRoleResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getServiceIdentityRoleWithOptions(headers, runtime);
}

model ListHpoExperimentLogsRequest {
  logName?: string(name='LogName', description='Log name to be listed.', example='nnimanager.log'),
  pageNumber?: int32(name='PageNumber', description='The page number of the returned page.', example='1'),
  pageSize?: int32(name='PageSize', description='The number of entries per page.', example='40'),
}

model ListHpoExperimentLogsResponseBody = {
  code?: string(name='Code', description='Error code.', example='SUCCESS'),
  detail?: map[string]any(name='Detail', description='Extra error message.', example='{}'),
  logs?: [ string ](name='Logs', description='The log.'),
  message?: string(name='Message', description='The error message returned.', example='Missing \\\\"user_id\\\\" in request.'),
  requestId?: string(name='RequestId', description='The request ID.', example='071A904D-5A49-597F-9F69-81C7701D04AC'),
  totalCount?: int32(name='TotalCount', description='The total number of entries.', example='467'),
}

model ListHpoExperimentLogsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListHpoExperimentLogsResponseBody(name='body'),
}

/**
 * @summary list the content of a specified hpo experiment log
 *
 * @param request ListHpoExperimentLogsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListHpoExperimentLogsResponse
 */
async function listHpoExperimentLogsWithOptions(ExperimentId: string, request: ListHpoExperimentLogsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListHpoExperimentLogsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.logName)) {
    query['LogName'] = request.logName;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListHpoExperimentLogs',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}/logs`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary list the content of a specified hpo experiment log
 *
 * @param request ListHpoExperimentLogsRequest
 * @return ListHpoExperimentLogsResponse
 */
async function listHpoExperimentLogs(ExperimentId: string, request: ListHpoExperimentLogsRequest): ListHpoExperimentLogsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listHpoExperimentLogsWithOptions(ExperimentId, request, headers, runtime);
}

model ListHpoExperimentsRequest {
  accessibility?: string(name='Accessibility', description='The accessibility of the experiments to be listed.', example='PRIVATE'),
  creator?: string(name='Creator', description='Who created the expriment.', example='266977839132045194'),
  includeConfigData?: string(name='IncludeConfigData', description='Return experiment detailed configuration or not.', example='True, False'),
  maxCreateTime?: string(name='MaxCreateTime', description='The maximum create time of the experiment.', example='yyyy-mm-dd hh:mm:ss或着yyyy-mm-dd，比如2023-03-31 10:29:30'),
  minCreateTime?: string(name='MinCreateTime', description='The minimum create time of the experiment.', example='yyyy-mm-dd hh:mm:ss或着yyyy-mm-dd，比如2023-03-31 10:29:30'),
  name?: string(name='Name', description='Experiment name filter.', example='my_hpo_exp_1'),
  order?: string(name='Order', description='ASC, DESC.', example='ASC, DESC.'),
  pageNumber?: int32(name='PageNumber', description='The page number.

Default value: 1.', example='1'),
  pageSize?: int32(name='PageSize', description='Record number on each page', example='10'),
  sortBy?: string(name='SortBy', description='The returned experiments to be sorted by this column.', example='GmtCreateTime'),
  status?: string(name='Status', description='Experiment status to be listed.', example='CREATED, RUNNING, FINISHED, FAILED, EARLY_STOPPED, USER_CANCELED, SYS_CANCELED, WAITING, NO_MORE_TRIAL, UNKNOWN'),
  workspaceId?: string(name='WorkspaceId', description='The AI workspace ID the experiments belongs to.', example='default'),
}

model ListHpoExperimentsResponseBody = {
  code?: string(name='Code', description='Error code.', example='INVALID_INPUT_PARAMS'),
  detail?: map[string]string(name='Detail', description='Extra error information.'),
  experiments?: [ 
    {
      accessibility?: string(name='Accessibility', description='Experiment accessibility, private or public.', example='PUBLIC'),
      configIni?: string(name='ConfigIni', description='Experiment job run environment configurations.', example='[odps_config]
key1 = value1
key2 = value2'),
      configYml?: string(name='ConfigYml', description='HPO experiment run configuration.', example='experimentName: dlc_oss_mnist
experimentWorkingDirectory: ../expdir
searchSpaceFile: search_space.json
trialCommand: python3 -m hpo_tools.core.utils.run --config=./trial.ini
trialConcurrency: 1
maxTrialNumber: 4
tuner:
  name: TPE
  classArgs:
    optimize_mode: maximize
trainingService:
  platform: local
assessor:
  name: PAIAssessor
  classArgs:
    optimize_mode: maximize
    start_step: 2'),
      creator?: string(name='Creator', description='The one who created the experiment.', example='1049310008714189'),
      deleted?: boolean(name='Deleted', description='If the experiment is deleted.', example='1'),
      description?: string(name='Description', description='The description of the experiment.', example='desc'),
      experimentId?: string(name='ExperimentId', description='Experiment ID.', example='sORVEck'),
      gmtCreateTime?: string(name='GmtCreateTime', description='Experiment Create Time.', example='2023-03-31T10:29:30Z'),
      gmtModifiedTime?: string(name='GmtModifiedTime', description='Last modified time.', example='2022-10-27T00:55:54Z'),
      jobType?: string(name='JobType', description='Experimetn job type.', example='1'),
      name?: string(name='Name', description='Experiment name', example='my experiment x'),
      searchSpace?: string(name='SearchSpace', description='Experiment hyperparameter search space.', example='{\\\\"foo\\\\":\\\\"bar\\\\"}'),
      status?: string(name='Status', description='Experiment status.', example='CREATED, RUNNING, FINISHED, FAILED, EARLY_STOPPED, USER_CANCELED, SYS_CANCELED, WAITING, NO_MORE_TRIAL, UNKNOWN'),
      trialCount?: int32(name='TrialCount', description='How many trials the experiment have.', example='20'),
      trialStatus?: map[string]string(name='TrialStatus', description='Trial status map.'),
      workspaceId?: string(name='WorkspaceId', description='The ID of the AI workspace.', example='foo'),
    }
  ](name='Experiments', description='experiment array.'),
  message?: string(name='Message', description='Error message.', example='Missing \\\\"user_id\\\\" in request.'),
  requestId?: string(name='RequestId', description='The request ID.', example='3F190916-B3E5-5D1E-AD0C-35C0DF105F51'),
  totalCount?: int32(name='TotalCount', description='Total qualified experiment count.', example='5'),
}

model ListHpoExperimentsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListHpoExperimentsResponseBody(name='body'),
}

/**
 * @summary List HPO experiments
 *
 * @param request ListHpoExperimentsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListHpoExperimentsResponse
 */
async function listHpoExperimentsWithOptions(request: ListHpoExperimentsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListHpoExperimentsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.accessibility)) {
    query['Accessibility'] = request.accessibility;
  }
  if (!Util.isUnset(request.creator)) {
    query['Creator'] = request.creator;
  }
  if (!Util.isUnset(request.includeConfigData)) {
    query['IncludeConfigData'] = request.includeConfigData;
  }
  if (!Util.isUnset(request.maxCreateTime)) {
    query['MaxCreateTime'] = request.maxCreateTime;
  }
  if (!Util.isUnset(request.minCreateTime)) {
    query['MinCreateTime'] = request.minCreateTime;
  }
  if (!Util.isUnset(request.name)) {
    query['Name'] = request.name;
  }
  if (!Util.isUnset(request.order)) {
    query['Order'] = request.order;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.sortBy)) {
    query['SortBy'] = request.sortBy;
  }
  if (!Util.isUnset(request.status)) {
    query['Status'] = request.status;
  }
  if (!Util.isUnset(request.workspaceId)) {
    query['WorkspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListHpoExperiments',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiments`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary List HPO experiments
 *
 * @param request ListHpoExperimentsRequest
 * @return ListHpoExperimentsResponse
 */
async function listHpoExperiments(request: ListHpoExperimentsRequest): ListHpoExperimentsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listHpoExperimentsWithOptions(request, headers, runtime);
}

model ListHpoTrialCommandsResponseBody = {
  code?: string(name='Code', description='The status code.', example='INVALID_USER_OR_EXP'),
  commands?: [ 
    {
      command?: string(name='Command', description='The command that you want to run.', example='dlc submit pytorch --name=test_nni_foo_bar'),
      id?: int32(name='Id', description='The id of the command.', example='1'),
      output?: string(name='Output', description='The output of the above command', example='dlc job submitted.'),
    }
  ](name='Commands', description='The list of commands.'),
  detail?: map[string]string(name='Detail', description='Extra error information.'),
  message?: string(name='Message', description='The error message returned.', example='Missing \\\\"user_id\\\\" in request.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='071A904D-5A49-597F-9F69-81C7701D04AC'),
}

model ListHpoTrialCommandsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListHpoTrialCommandsResponseBody(name='body'),
}

/**
 * @summary 返回一个trial所对应的任务里所有已经执行的命令
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListHpoTrialCommandsResponse
 */
async function listHpoTrialCommandsWithOptions(ExperimentId: string, TrialId: string, headers: map[string]string, runtime: Util.RuntimeOptions): ListHpoTrialCommandsResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ListHpoTrialCommands',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}/trial/${OpenApiUtil.getEncodeParam(TrialId)}/commands`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 返回一个trial所对应的任务里所有已经执行的命令
 *
 * @return ListHpoTrialCommandsResponse
 */
async function listHpoTrialCommands(ExperimentId: string, TrialId: string): ListHpoTrialCommandsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listHpoTrialCommandsWithOptions(ExperimentId, TrialId, headers, runtime);
}

model ListHpoTrialLogNamesResponseBody = {
  code?: string(name='Code', description='Error code.', example='INVALID_INPUT_PARAMS'),
  detail?: map[string]string(name='Detail', description='Extra error information.'),
  logNames?: [ string ](name='LogNames', description='Existing log files.'),
  message?: string(name='Message', description='Error message.', example='Missing \\\\"user_id\\\\" in request.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='3F190916-B3E5-5D1E-AD0C-35C0DF105F51'),
}

model ListHpoTrialLogNamesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListHpoTrialLogNamesResponseBody(name='body'),
}

/**
 * @summary List all log file names a trial have.
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListHpoTrialLogNamesResponse
 */
async function listHpoTrialLogNamesWithOptions(ExperimentId: string, TrialId: string, headers: map[string]string, runtime: Util.RuntimeOptions): ListHpoTrialLogNamesResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ListHpoTrialLogNames',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}/trial/${OpenApiUtil.getEncodeParam(TrialId)}/lognames`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary List all log file names a trial have.
 *
 * @return ListHpoTrialLogNamesResponse
 */
async function listHpoTrialLogNames(ExperimentId: string, TrialId: string): ListHpoTrialLogNamesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listHpoTrialLogNamesWithOptions(ExperimentId, TrialId, headers, runtime);
}

model ListHpoTrialLogsRequest {
  logName?: string(name='LogName', description='Log file name.', example='trial.log'),
  pageNumber?: int32(name='PageNumber', description='The page number.', example='1'),
  pageSize?: int32(name='PageSize', description='The number of entries returned per page.', example='10'),
}

model ListHpoTrialLogsResponseBody = {
  code?: string(name='Code', description='Error code.', example='SUCCESS'),
  detail?: map[string]any(name='Detail', description='Extra error information.', example='{}'),
  logs?: [ string ](name='Logs', description='The log.'),
  message?: string(name='Message', description='Error message.', example='Missing \\\\"user_id\\\\" in request.'),
  requestId?: string(name='RequestId', description='The request ID.', example='3F190916-B3E5-5D1E-AD0C-35C0DF105F51'),
  totalCount?: int32(name='TotalCount', description='The total number of entries returned.', example='123'),
}

model ListHpoTrialLogsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListHpoTrialLogsResponseBody(name='body'),
}

/**
 * @summary List Trial log lines
 *
 * @param request ListHpoTrialLogsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListHpoTrialLogsResponse
 */
async function listHpoTrialLogsWithOptions(ExperimentId: string, TrialId: string, request: ListHpoTrialLogsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListHpoTrialLogsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.logName)) {
    query['LogName'] = request.logName;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListHpoTrialLogs',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}/trial/${OpenApiUtil.getEncodeParam(TrialId)}/logs`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary List Trial log lines
 *
 * @param request ListHpoTrialLogsRequest
 * @return ListHpoTrialLogsResponse
 */
async function listHpoTrialLogs(ExperimentId: string, TrialId: string, request: ListHpoTrialLogsRequest): ListHpoTrialLogsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listHpoTrialLogsWithOptions(ExperimentId, TrialId, request, headers, runtime);
}

model ListHpoTrialsRequest {
  order?: string(name='Order', description='The trial results order.', example='ASC'),
  pageNumber?: int32(name='PageNumber', description='The number of the page to return.', example='1'),
  pageSize?: int32(name='PageSize', description='The number of entries returned per page.', example='10'),
  sortBy?: string(name='SortBy', description='The results to be sorted by which column.', example='GmtCreateTime'),
}

model ListHpoTrialsResponseBody = {
  code?: string(name='Code', description='Error code.', example='INVALID_USER_OR_EXP'),
  detail?: map[string]string(name='Detail', description='Extra error information.'),
  message?: string(name='Message', description='The error message returned.', example='Missing \\\\"user_id\\\\" in request.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='3F190916-B3E5-5D1E-AD0C-35C0DF105F51'),
  totalCount?: int32(name='TotalCount', description='The total number of entries qualified.', example='5'),
  trials?: [ 
    {
      experimentId?: string(name='ExperimentId'),
      finalMetric?: string(name='FinalMetric'),
      gmtCreateTime?: string(name='GmtCreateTime'),
      gmtModifiedTime?: string(name='GmtModifiedTime'),
      hyperparam?: string(name='Hyperparam'),
      jobMeta?: string(name='JobMeta'),
      metric?: string(name='Metric'),
      metricName?: string(name='MetricName'),
      model?: string(name='Model'),
      parameterId?: int32(name='ParameterId'),
      status?: string(name='Status'),
      trialId?: string(name='TrialId'),
      userComment?: string(name='UserComment'),
      userScore?: int32(name='UserScore'),
    }
  ](name='Trials', description='Trial array.'),
}

model ListHpoTrialsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListHpoTrialsResponseBody(name='body'),
}

/**
 * @summary List HPO trials
 *
 * @param request ListHpoTrialsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListHpoTrialsResponse
 */
async function listHpoTrialsWithOptions(ExperimentId: string, request: ListHpoTrialsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListHpoTrialsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.order)) {
    query['Order'] = request.order;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.sortBy)) {
    query['SortBy'] = request.sortBy;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListHpoTrials',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}/trials`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary List HPO trials
 *
 * @param request ListHpoTrialsRequest
 * @return ListHpoTrialsResponse
 */
async function listHpoTrials(ExperimentId: string, request: ListHpoTrialsRequest): ListHpoTrialsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listHpoTrialsWithOptions(ExperimentId, request, headers, runtime);
}

model RestartHpoTrialsRequest {
  trialHyperParameters?: string(name='TrialHyperParameters', description='A hyperparameter combination instance.', example='‘{"${batch_size}": "32", "${lr}": "0.01"}\\\\"'),
  trialIds?: [ string ](name='TrialIds', description='Trial ID array.'),
}

model RestartHpoTrialsResponseBody = {
  code?: string(name='Code', description='Response code.', example='INVALID_USER_OR_EXP'),
  detail?: map[string]string(name='Detail', description='Extra error information.'),
  message?: string(name='Message', description='Error message.', example='Missing \\\\"user_id\\\\" in request.'),
  requestId?: string(name='RequestId', description='Id of the request', example='3F190916-B3E5-5D1E-AD0C-35C0DF105F51'),
  results?: map[string]any(name='Results', description='Restart status of all the trial IDs.', example='{
\\\\"xrYq99\\\\": TrialJobInfo text,
\\\\"xrYq9N\\\\":TrialJobInfo text
}'),
}

model RestartHpoTrialsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: RestartHpoTrialsResponseBody(name='body'),
}

/**
 * @summary Restart HPO trials
 *
 * @param request RestartHpoTrialsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return RestartHpoTrialsResponse
 */
async function restartHpoTrialsWithOptions(ExperimentId: string, request: RestartHpoTrialsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): RestartHpoTrialsResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.trialHyperParameters)) {
    body['TrialHyperParameters'] = request.trialHyperParameters;
  }
  if (!Util.isUnset(request.trialIds)) {
    body['TrialIds'] = request.trialIds;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RestartHpoTrials',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}/restart_trials`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Restart HPO trials
 *
 * @param request RestartHpoTrialsRequest
 * @return RestartHpoTrialsResponse
 */
async function restartHpoTrials(ExperimentId: string, request: RestartHpoTrialsRequest): RestartHpoTrialsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return restartHpoTrialsWithOptions(ExperimentId, request, headers, runtime);
}

model StopHpoExperimentResponseBody = {
  code?: string(name='Code', description='Response code.', example='INVALID_INPUT_PARAMS'),
  detail?: map[string]string(name='Detail', description='Extra error information.'),
  expId?: string(name='ExpId', description='Experiment ID', example='sHpITOH'),
  message?: string(name='Message', description='Error message.', example='Missing \\\\"user_id\\\\" in request.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='071A904D-5A49-597F-9F69-81C7701D04AC'),
  status?: string(name='Status'),
}

model StopHpoExperimentResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: StopHpoExperimentResponseBody(name='body'),
}

/**
 * @summary calling hpo StopExperiment
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return StopHpoExperimentResponse
 */
async function stopHpoExperimentWithOptions(ExperimentId: string, headers: map[string]string, runtime: Util.RuntimeOptions): StopHpoExperimentResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'StopHpoExperiment',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}/stop`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary calling hpo StopExperiment
 *
 * @return StopHpoExperimentResponse
 */
async function stopHpoExperiment(ExperimentId: string): StopHpoExperimentResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return stopHpoExperimentWithOptions(ExperimentId, headers, runtime);
}

model StopHpoTrialsRequest {
  trialIds?: [ string ](name='TrialIds', description='Trial Ids to be stopped.'),
}

model StopHpoTrialsResponseBody = {
  code?: string(name='Code', description='Error code.', example='INVALID_USER_OR_EXP'),
  detail?: map[string]string(name='Detail', description='Extra error information.'),
  message?: string(name='Message', description='Error message.', example='failed to stop any trial'),
  requestId?: string(name='RequestId', description='The request ID.', example='071A904D-5A49-597F-9F69-81C7701D04AC'),
  results?: map[string]any(name='Results', description='The results of trial stop.', example='{
    \\\\"xrYq99\\\\":\\\\"successfully stopped trial,\\\\",
    \\\\"xrYq9N\\\\":\\\\"failed to stop trial,\\\\"
}'),
}

model StopHpoTrialsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: StopHpoTrialsResponseBody(name='body'),
}

/**
 * @summary Stop an HPO trial.
 *
 * @param request StopHpoTrialsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return StopHpoTrialsResponse
 */
async function stopHpoTrialsWithOptions(ExperimentId: string, request: StopHpoTrialsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): StopHpoTrialsResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.trialIds)) {
    body['TrialIds'] = request.trialIds;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'StopHpoTrials',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}/stop_trials`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Stop an HPO trial.
 *
 * @param request StopHpoTrialsRequest
 * @return StopHpoTrialsResponse
 */
async function stopHpoTrials(ExperimentId: string, request: StopHpoTrialsRequest): StopHpoTrialsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return stopHpoTrialsWithOptions(ExperimentId, request, headers, runtime);
}

model UpdateHpoExperimentRequest {
  accessibility?: string(name='Accessibility', description='Experiment accessibility, private or public.', example='PRIVATE'),
  description?: string(name='Description', description='Experiment description.', example='This is an AutoML HPO experiment.'),
  hpoExperimentConfiguration?: HpoExperimentConfig(name='HpoExperimentConfiguration', description='Experiment configuration.'),
  name?: string(name='Name', description='Experiment name.', example='my experiment x'),
  workspaceId?: string(name='WorkspaceId', description='Expeirment\\\\"s AI workspace ID.', example='12345'),
}

model UpdateHpoExperimentResponseBody = {
  code?: string(name='Code', description='Error code.', example='SUCCESS'),
  detail?: map[string]any(name='Detail', description='Extra error information.', example='{}'),
  message?: string(name='Message', description='Error message.', example='Missing \\\\"user_id\\\\" in request.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='3F190916-B3E5-5D1E-AD0C-35C0DF105F51'),
}

model UpdateHpoExperimentResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateHpoExperimentResponseBody(name='body'),
}

/**
 * @summary Update a running HPO experiment\\"s configuration
 *
 * @param request UpdateHpoExperimentRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateHpoExperimentResponse
 */
async function updateHpoExperimentWithOptions(ExperimentId: string, request: UpdateHpoExperimentRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateHpoExperimentResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.accessibility)) {
    body['Accessibility'] = request.accessibility;
  }
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.hpoExperimentConfiguration)) {
    body['HpoExperimentConfiguration'] = request.hpoExperimentConfiguration;
  }
  if (!Util.isUnset(request.name)) {
    body['Name'] = request.name;
  }
  if (!Util.isUnset(request.workspaceId)) {
    body['WorkspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateHpoExperiment',
    version = '2022-08-28',
    protocol = 'HTTPS',
    pathname = `/api/automl/v1/hpo/experiment/${OpenApiUtil.getEncodeParam(ExperimentId)}/update`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary Update a running HPO experiment\\"s configuration
 *
 * @param request UpdateHpoExperimentRequest
 * @return UpdateHpoExperimentResponse
 */
async function updateHpoExperiment(ExperimentId: string, request: UpdateHpoExperimentRequest): UpdateHpoExperimentResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateHpoExperimentWithOptions(ExperimentId, request, headers, runtime);
}

